import { Component, Input, OnInit } from '@angular/core';

@Component({
  selector: 'app-calc-result',
  templateUrl: './calc-result.component.html',
  styleUrls: ['./calc-result.component.scss']
})
export class CalcResultComponent implements OnInit {

  constructor() { }

  active1 = false
  active2 = false
  active3 = true
  active4 = false
  @Input() data: any
  // {
  //   "score1": "0.72",
  //   "score2": "0.54",
  //   "score3": "0.51",
  //   "score4": "0.42",
  //   "total1": "0.05",
  //   "total2": "0.23",
  //   "total3": "0.13",
  //   "total4": "0.59",
  //   "eco1": "0.83",
  //   "eco2": "0.17",
  //   "env1": "0.77",
  //   "env2": "0.09",
  //   "env3": "0.20",
  //   "social1": "0.64",
  //   "social2": "0.26",
  //   "social3": "0.10"
  // }

  ngOnInit() {



  }

  ngOnChanges() {

    //TODO:
    if (!this.data) return
    this.active1 = this.active2 = this.active3 = this.active4 = false
    let { score1, score2, score3, score4 } = this.data;
    this.active1 = score1 > Math.max(score2, score3, score4)
    this.active2 = score2 > Math.max(score1, score3, score4)
    this.active3 = score3 > Math.max(score2, score1, score4)
    this.active4 = score4 > Math.max(score2, score3, score1)
  }

}
